<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html>
<html>
<head>
<title>商品列表</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="css/bootstrap.css" />
</head>
<body>
	<div class="container-fluid">

		<!-- header -->
		<jsp:include page="/admin/header.jsp" flush="true"></jsp:include>
		<!--//header  -->

		<div class="text-right">
			<a class="btn btn-warning"
				href="${pageContext.request.contextPath }/admin/goods_add.jsp">添加商品</a>
		</div>

		<br>
		<c:if test="${!empty msg }">
			<div class="alert alert-success">${msg }</div>
		</c:if>
		<c:if test="${!empty failMsg }">
			<div class="alert alert-danger">${failMsg }</div>
		</c:if>
		<br>

		<ul role="tablist" class="nav nav-tabs">
			<li <c:if test="${type==0 }">class="active"</c:if>
				role="presentation"><a
				href="${pageContext.request.contextPath }/admin/goods_list">全部商品</a></li>
			<li <c:if test="${type==1 }">class="active"</c:if>
				role="presentation"><a
				href="${pageContext.request.contextPath }/admin/goods_list?type=1">条幅推荐</a></li>
			<li <c:if test="${type==2 }">class="active"</c:if>
				role="presentation"><a
				href="${pageContext.request.contextPath }/admin/goods_list?type=2">热销推荐</a></li>
			<li <c:if test="${type==3 }">class="active"</c:if>
				role="presentation"><a
				href="${pageContext.request.contextPath }/admin/goods_list?type=3">新品推荐</a></li>
		</ul>

		<br>

		<table class="table table-bordered table-hover">

			<tr>
				<th width="5%">ID</th>
				<th width="10%">图片</th>
				<th width="10%">名称</th>
				<th width="20%">介绍</th>
				<th width="10%">价格</th>
				<th width="10%">类目</th>
				<th width="25%">操作</th>
			</tr>

			<c:forEach items="${p.list }" var="g">
				<tr>
					<td><p>${g.id }</p></td>
					<td><p>
							<a
								href="${pageContext.request.contextPath }/goods_detail?id=${g.id }"
								target="_blank"><img
								src="${pageContext.request.contextPath }${g.cover }"
								width="100px" height="100px"></a>
						</p></td>
					<td><p>
							<a
								href="${pageContext.request.contextPath }/goods_detail?id=${g.id }"
								target="_blank">${g.name }</a>
						</p></td>
					<td><p>${g.intro }</p></td>
					<td><p>${g.price }</p></td>
					<td><p>${g.type.name }</p></td>
					<td>
						<p>
							<c:choose>
								<c:when test="${g.isScroll }">
									<a class="btn btn-info"
										href="${pageContext.request.contextPath }/admin/recommend?state=0&typeTarget=1&id=${g.id }&type=${type }&pageNo=${p.pageNo }">移除条幅</a>
								</c:when>
								<c:otherwise>
									<a class="btn btn-primary"
										href="${pageContext.request.contextPath }/admin/recommend?state=1&typeTarget=1&id=${g.id }&type=${type }&pageNo=${p.pageNo }">添加条幅</a>
								</c:otherwise>
							</c:choose>
							<c:choose>
								<c:when test="${g.isHot }">
									<a class="btn btn-info"
										href="${pageContext.request.contextPath }/admin/recommend?state=0&typeTarget=2&id=${g.id }&type=${type }&pageNo=${p.pageNo }">移除热销</a>
								</c:when>
								<c:otherwise>
									<a class="btn btn-primary"
										href="${pageContext.request.contextPath }/admin/recommend?state=1&typeTarget=2&id=${g.id }&type=${type }&pageNo=${p.pageNo }">添加热销</a>
								</c:otherwise>
							</c:choose>
							<c:choose>
								<c:when test="${g.isNew }">
									<a class="btn btn-info"
										href="${pageContext.request.contextPath }/admin/recommend?state=0&typeTarget=3&id=${g.id }&type=${type }&pageNo=${p.pageNo }">移除新品</a>
								</c:when>
								<c:otherwise>
									<a class="btn btn-primary"
										href="${pageContext.request.contextPath }/admin/recommend?state=1&typeTarget=3&id=${g.id }&type=${type }&pageNo=${p.pageNo }">添加新品</a>
								</c:otherwise>
							</c:choose>
						</p> <a class="btn btn-success"
						href="${pageContext.request.contextPath }/admin/goods_editShow?id=${g.id }&pageNo=${p.pageNo }&type=${type } ">修改</a>
						<a class="btn btn-danger"
						href="${pageContext.request.contextPath }/admin/goods_delete?id=${g.id}&pageNo=${p.pageNo }&type=${type }">删除</a>
					</td>
				</tr>
			</c:forEach>

		</table>

		<br>

		<!-- header -->
		<jsp:include page="../page.jsp" flush="true">
			<jsp:param value="/admin/goods_list" name="url" />
			<jsp:param value="&type=${type }" name="param" />
		</jsp:include>
		<!--//header  -->

		<br>
	</div>
</body>
</html>